#pragma once
#include "Value.h"

template<class T>
class Container
{
public:
	Container();
	Container(const Container<T> &Source)
	{
		Objects = NULL;
		Count = 0;
		Ref++;
		if(Ref == 1)
			Error = new T;
		Parent = NULL;
		Copy(Source);
	}
	~Container();
	Container<T> & operator = (const Container<T> &Source);
	bool Add(const T &Object);
	bool RemoveAtIndex(const Value &Index);
	int Size() const;
	bool Clear();
	T& operator[] (const Value &Index) const;
	static T *Error;
	T *Parent;
protected:
	T **Objects;
	int Count;
	static int Ref;
	void Copy(const Container<T> &Source);
};

template<class T>
class Container<T *>
{
public:
	Container();
	Container(const Container<T*> &Source)
	{
		Objects = NULL;
		Count = 0;
		Ref++;
		if(Ref == 1)
			Error = new T;
		Parent = NULL;
		Copy(Source);
	}
	~Container();
	Container<T*> & operator = (const Container<T*> &Source);
	bool Add(T &Object);
	bool Add(const T *Object);
	bool RemoveAtIndex(const Value &Index);
	int Size() const;
	bool Clear();
	T& operator[] (const Value &Index) const;
	static T *Error;
	T *Parent;
protected:
	T **Objects;
	int Count;
	static int Ref;
	void Copy(const Container<T*> &Source);
};

#include "..\Shared\Container.template"